package com.relytosoft.mizar.analyze.base.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wss
 * @version 1.0
 * @date 2022/5/17 14:35
 */
public enum IndexNameTypeEnum {

    AY_BEHAVIOR("BEHAVIOR", "ay_behavior_"),
    AY_STRUCTURE("STRUCTURE", "ay_structure_"),
    AY_FACE("FACE", "relyto_face_"),
    AY_CONTROL_FACE("CONTROL_FACE", "relyto_control_face_"),
    AY_STRUCTURE_MOTOR_VEHICLE("MOTOR_VEHICLE", "relyto_structure_vehicle_"),
    AY_STRUCTURE_NON_MOTOR_VEHICLE("NON_MOTOR_VEHICLE", "relyto_structure_non_vehicle_"),
    AY_STRUCTURE_PERSON("PERSON", "relyto_structure_person_");

    private final String code;
    private final String message;

    private IndexNameTypeEnum(final String code, final String message) {
        this.code = code;
        this.message = message;
    }

    public static String getMsgByCode(final String code) {
        if (code == null) {
            return null;
        }
        final IndexNameTypeEnum enumList = getByCode(code);
        if (enumList == null) {
            return null;
        }
        return enumList.getMessage();
    }

    public static IndexNameTypeEnum getByCode(final String code) {
        for (final IndexNameTypeEnum enumList : values()) {
            if (enumList.getCode().equals(code)) {
                return enumList;
            }
        }
        return null;
    }

    public static List<IndexNameTypeEnum> getAllEnum() {
        final List<IndexNameTypeEnum> list = new ArrayList<IndexNameTypeEnum>(values().length);
        for (final IndexNameTypeEnum enumList : values()) {
            list.add(enumList);
        }
        return list;
    }

    public static List<String> getAllEnumCode() {
        final List<String> list = new ArrayList<String>(values().length);
        for (final IndexNameTypeEnum enumList : values()) {
            list.add(enumList.getCode());
        }
        return list;
    }

    public String getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

}
